package com.dm.cloud.auth.mapper;

import com.dm.cloud.tkmybatis.service.BaseMapper;
import com.dm.cloud.auth.common.po.AuthUser;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
   * @author hcx
   * @type AuthUserMapper.java
   * @desc AuthUser mapper
   */

@Mapper
public interface AuthUserMapper extends BaseMapper<AuthUser> {

    @Select("select * from T_AUTH_USER where user_name=#{username}")
    AuthUser findByUserName(@Param("username") String username);

    @Select("select u.id,u.CHINESE_NAME chineseName,u.freeze " +
            "from " +
            "t_auth_user u " +
            "INNER JOIN t_auth_user_role ur on ur.USER_ID=u.id " +
            "where " +
            "ur.role_id=(select rp.ROLE_ID from t_auth_role_permission rp INNER JOIN t_auth_permission ps on ps.code= rp.PERMISSION_ID where ps.APP_CODE=#{appCode} GROUP BY rp.ROLE_ID);")
    List<AuthUser> findByAppCode(@Param("appCode") String appCode);
}
